Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IN PROGRESS] refactor: Refactor scrollable table widgets #265

Closed
wants to merge 1 commit into from

Conversation

ClementTsang
Copy link
Owner

@ClementTsang ClementTsang commented Oct 12, 2020

Description

A description of the change and what it does. If relevant, please provide screenshots of what results from the change:

The goal of this refactor is to help reduce some duplicated code, and make it easier to add new widgets as required. To start, this will mostly be targeting scrollable table widgets, since they're some of the more complicated widgets in terms of state management and user interaction.


The main idea behind this change is to move on from the current system of each widget having three separated parts:

  • State management
  • Drawing management
  • Event management (managed mostly within app.rs)

The biggest issue was that adding a new widget was painful to say the least - you would have to create a new state manager, write new code to handle events, and then write drawing code! To address this, I was planning on refactoring this AFTER 0.5.0 released, but given how much trouble this was giving me during the config implementation planning, I decided to do some of this now.

The new concept planned (and implemented for scrollable tables for now) is:

  • Introduce "components" that represent base parts of a widget. So for things like processes, disks, etc., these are all scrollable tables. As such, the ScrollableTable trait would represent the base methods we want all scrollable tables to have. This means I don't have to have 5 different implementations of how to increment the table scroll cursor.

  • Unify widget state management and drawing together. Since we already keep track of all these widget states within the overarching app state, we can just simply call the widget's drawing function.

Type of change

Remove the irrelevant ones:

  • Refactoring (a change that doesn't change application functionality)

Test methodology

If relevant, please state how this was tested:

Furthermore, please tick which platforms this change was tested on:

  • Windows
  • macOS
  • Linux

If relevant, all of these platforms should be tested.

Checklist

If relevant, ensure the following have been met:

  • Change has been tested to work, and does not cause new breakage unless intended
  • Code has been self-reviewed
  • Documentation has been added/updated if needed (README, help menu, etc.)
  • Passes Travis tests (clippy check and cargo test check)
  • Areas your change affects have been linted using rustfmt (cargo fmt)
  • No merge conflicts arise from the change

@ClementTsang ClementTsang changed the title [IN PROGRESS] refactor: Add components to make adding new GUI elements easier [IN PROGRESS] refactor: Refactor scrollable list widgets Oct 13, 2020
@ClementTsang ClementTsang changed the title [IN PROGRESS] refactor: Refactor scrollable list widgets [IN PROGRESS] refactor: Refactor scrollable table widgets Oct 13, 2020
@ClementTsang ClementTsang force-pushed the create_components branch 6 times, most recently from 6ab6e12 to 1647df6 Compare October 14, 2020 04:35
@ClementTsang
Copy link
Owner Author

Closing this, going to start over as part of dealing with #374.

@ClementTsang ClementTsang deleted the create_components branch May 5, 2021 04:09
@ClementTsang ClementTsang mentioned this pull request May 16, 2022
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant